﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using SharePointListSecurity.Data;

namespace SharePointListSecurity.Model
{
    public class SharepointViewSecurityService
    {
        #region members
        readonly SPListSecurityContextDataContext context;
        readonly SPWeb spWeb;
        SPUser currentUser;
        #endregion

        public SharepointViewSecurityService()
        {
            this.spWeb = SPContext.Current.Web;
            context = new SPListSecurityContextDataContext(spWeb.Site.Url);
            currentUser = spWeb.CurrentUser;
        }

        public bool IsViewExcluded(SPList list, ViewFormat viewFormat)
        {
            IEnumerable<EditFormFieldsPermissions> editPermissionsReadOnlyEdit = context.EditFormFieldsPermissions
                                                                    .Where(p => new Guid(p.ListID) == list.ID
                                                                    && (p.DisplayMode == PermissionType.ReadOnly ||
                                                                        p.DisplayMode == PermissionType.Editable)
                                                                    );

            return false;
        }
    }
}
